﻿using System.Drawing;
using ZedGraph;

/// <summary>
/// GraphStyle 的摘要说明
/// </summary>
public class MyGraphStyle
{
    static MyGraphStyle()
    {
        //
        // TODO: 在此处添加构造函数逻辑
        //
    }

    public static void BuildbarGraphStyle(GraphPane mypane)
    {
        GraphPane Mypane = mypane;
        Mypane.XAxis.Scale.FontSpec.Angle = 270f;
        //Mypane.XAxis.MajorTic.IsOpposite = false;
        //Mypane.XAxis.MinorTic.IsOpposite = false;
        //Mypane.YAxis.MajorTic.IsOpposite = false;
        //Mypane.YAxis.MinorTic.IsOpposite = false;
        //Mypane.YAxis.Scale.IsSkipFirstLabel = true;
        //Mypane.XAxis.Scale.IsPreventLabelOverlap = false;
        //Mypane.YAxis.Cross = 30.0;
        Mypane.XAxis.CrossAuto = true;
        Mypane.YAxis.Scale.IsUseTenPower = true;
        Mypane.YAxis.MajorGrid.IsVisible = true;
        Mypane.XAxis.MajorGrid.IsVisible = true;
        Mypane.Border = new Border(true, Color.FromArgb(240, 240, 240), 0);
        Mypane.Chart.Fill = new Fill(Color.White, Color.FromArgb(255, 255, 255), 45F); // Fill the axis background with a color gradient
        Mypane.Fill = new Fill(Color.FromArgb(240, 240, 240), Color.FromArgb(240, 240, 240), 45F);
        Mypane.Legend.Position = LegendPos.InsideTopRight;
    }

    public static void BuildbarGraphStyleforSPC(GraphPane mypane)
    {
        GraphPane Mypane = mypane;
        //Mypane.XAxis.Scale.FontSpec.Angle = 270f;
        //Mypane.XAxis.MajorTic.IsOpposite = false;
        //Mypane.XAxis.MinorTic.IsOpposite = false;
        //Mypane.YAxis.MajorTic.IsOpposite = false;
        //Mypane.YAxis.MinorTic.IsOpposite = false;
        //Mypane.YAxis.Scale.IsSkipFirstLabel = true;
        //Mypane.XAxis.Scale.IsPreventLabelOverlap = false;
        //Mypane.YAxis.Cross = 30.0;
        Mypane.XAxis.CrossAuto = true;
        Mypane.YAxis.Scale.IsUseTenPower = true;
        Mypane.YAxis.MajorGrid.IsVisible = false;
        Mypane.XAxis.MajorGrid.IsVisible = false;
        Mypane.Border = new Border(true, Color.FromArgb(240, 240, 240), 0);
        Mypane.Chart.Fill = new Fill(Color.White, Color.FromArgb(255, 255, 255), 45F); // Fill the axis background with a color gradient
        Mypane.Fill = new Fill(Color.FromArgb(240, 240, 240), Color.FromArgb(240, 240, 240), 45F);
    }

    public static void BuildpieGraphStyle(GraphPane mypane)
    {
        GraphPane Mypane = mypane;
        Mypane.Legend.IsVisible = false;
        Mypane.Title.FontSpec.IsAntiAlias = true;
        Mypane.Title.FontSpec.Size = 20f;
        Mypane.Title.FontSpec.IsBold = false;        
        Mypane.Border = new Border(true, Color.FromArgb(240, 240, 240), 0);
        Mypane.Chart.Fill = new Fill(Color.FromArgb(240, 240, 240), Color.FromArgb(240, 240, 240), 45F); // Fill the axis background with a color gradient
        Mypane.Fill = new Fill(Color.FromArgb(240, 240, 240), Color.FromArgb(240, 240, 240), 45F);
    }

    public static void BuildbatItem(BarItem myBarItem)
    {
        BarItem MyBarItem = myBarItem;
    }

    public static void BuildLineItem(LineItem myLineItem)
    {
        LineItem MyLineItem = myLineItem;
        MyLineItem.Line.IsAntiAlias = true;
    }

    public static void BuildPieItem(PieItem myPieItem)
    {
        PieItem MyPieItem = myPieItem;
        MyPieItem.LabelDetail.FontSpec.Size = 15f;
        MyPieItem.LabelType = PieLabelType.Name_Percent;
    }
}
